<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="utf-8" />
    <title>钉钉测试</title>
    <meta name="viewport"
        content="width=device-width, initial-scale=1,maximum-scale=1.0,user-scalable=no,viewport-fit=cover" />
    <script src="https://g.alicdn.com/dingding/dingtalk-jsapi/3.0.25/dingtalk.open.js"></script>
    <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
    <script>
        var vConsole = new VConsole();
    </script>
</head>

<body>

    <button onclick="showToast()">点击弹出toast</button>
    <button onclick="showSelectContact()">点击选择联系人</button>
    <button onclick="showChat()">选择对话</button>

</body>

</html>


<script>
    function showToast() {

        dd.showToast({
            type: 'success',
            content: '这是一个toast提示',
            duration: 2000,
            success: (e) => {
                console.log('toast显示成功');
            },
            fail: () => {
                console.log('toast显示失败');
            },
            complete: () => {
                console.log('toast显示完成');
            },
        });
    }


    function showSelectContact() {
        dd.choosePhonebook({
            title: '标题',
            maxUsers: 20,
            multiple: true,
            limitTips: '选择人数不能超过20个',
            success: (res) => {
                const { name, mobile, mediaId } = res;
            },
            fail: () => { },
            complete: () => { },
        });

    }

    function showChat() {

        dd.chooseChat({
            corpId: `ding5d6107670557cadf35c2f4657eb6378f`,
            isAllowCreateGroup: true,
            filterNotOwnerGroup: true,
            success: (res) => {
                const { title, chatId, openConversationId } = res;
            },
            fail: () => {},
            complete: () => {},
            });
    }

</script>